/*
 * Copyright user2010
 * All rights reserved
 */

package org.myorg.applitest.jdbc.connection;

import org.myorg.applitest.mysql.names.Names;
import org.myorg.applitest.jdbc.Def;
import java.sql.ResultSet;

/**
 *
 * @author user
 */
public class ConAddRegUsrPrt  extends ConAddRegUsrAbs{
    public ConAddRegUsrPrt() throws Exception {
        super();
    }

    @Override
    public boolean doJob(String user, String password) throws Exception {

        this._dbConnection_.connect("", user, password);
        this._dbConnection_.executeUpdate(Def.useDB(Names.db));
        this._dbConnection_.executeQuerry(Def.countElements(Names.tableUsr));
        ResultSet result = this._dbConnection_.getResult();
        Integer intLastId = 0;
        while(result.next())
        {
            intLastId = result.getInt(1);
        }
        intLastId++;
        String strId = intLastId.toString();

        String strCommand = Def.insertIntoTable(Names.tableUsr) +
            Def.addField(strId) +
            Def.addField(this.strIdentiteNom_) +
            Def.addField(this.strIdentitePrenom1_) +
            Def.addField(this.strIdentitePrenom2_) +
            Def.addField(this.strIdentitePrenom3_) +
            Def.addField("prt") +
            Def.addField(this.strIdentiteDateNaissance_) +
            Def.addField(this.strIdentiteSexe_) +
            Def.addField(this.strPersonnelMail_) +
            Def.addField(this.strTravailMail_) +
            Def.addField(this.strPersonnelFixe_) +
            Def.addField(this.strTravailFixe_) +
            Def.addField(this.strPersonnelPortable_) +
            Def.addField(this.strTravailPortable_) +
            Def.addField(this.strAdresseVoie_) +
            Def.addField(this.strAdresseNumero_) +
            Def.addField(this.strAdresseLigne1_) +
            Def.addField(this.strAdresseLigne2_) +
            Def.addField(this.strAdresseCode_) +
            Def.addField(this.strAdresseVille_) +
            Def.addField(this.strAdressePays_) +
            Def.addField(this.strLogin_) +
            Def.addLastField(this.strPassword_);

        this._dbConnection_.executeUpdate(strCommand);
        this._dbConnection_.disconnect();
       
       //*/

        return true;
    }


}
